#include "contactinfo.h"

void ContactInfo::copyContactInfo(ContactInfo * first, const ContactInfo * second)
{
    first->d.id = second->d.id;
    first->d.name = second->d.name;
    first->d.networkId = second->d.networkId;
    first->d.presence = second->d.presence;
    first->d.presenceText = second->d.presenceText;
}

ContactInfo& ContactInfo::operator =(const ContactInfo &other)
{
    copyContactInfo(this, &other);
    return *this;
}

ContactInfo::ContactInfo(const ContactInfo &other)
{
    copyContactInfo(this, &other);
}

ContactInfo::ContactInfo(const QString &id, const QString &networkId, QObject *parent) :
    QObject(parent)
{
    d.id = id;
    d.networkId = networkId;
    d.presence = Offline;
}

bool ContactInfo::isValid() const
{
    return (!d.networkId.isEmpty() && !d.id.isEmpty());
}

QString ContactInfo::networkId() const
{
    return d.networkId;
}

void ContactInfo::setNetworkId(const QString &networkId)
{
    d.networkId = networkId;
    emit changed(this);
}

QString ContactInfo::id() const
{
    return d.id;
}

void ContactInfo::setId(const QString &id)
{
    d.id = id;
    emit changed(this);
}

QString ContactInfo::name() const
{
    return d.name;
}

void ContactInfo::setName(const QString &firstName)
{
    d.name = firstName;
    emit changed(this);
}

ContactInfo::Presence ContactInfo::presence() const
{
    return static_cast<ContactInfo::Presence>(d.presence);
}

void ContactInfo::setPresence(Presence presence)
{
    d.presence = presence;
    emit changed(this);
}

QString ContactInfo::presenceText() const
{
    return d.presenceText;
}

void ContactInfo::setPresenceText(const QString &text)
{
    d.presenceText = text;
    emit changed(this);
}

QIcon ContactInfo::picture() const
{
    return QIcon(":/core/images/default-avatar.png");
}
